<?php
require_once("vcl/vcl.inc.php");
require_once("lib/db_connection.php");
//Includes
use_unit("components4phpfull/jtiframe.inc.php");
use_unit("components4phpfull/jtsitetheme.inc.php");
use_unit("platinumgrid/jtplatinumgrid.inc.php");
use_unit("forms.inc.php");
use_unit("extctrls.inc.php");
use_unit("stdctrls.inc.php");

//Class definition
class RouteLog2 extends Page
{
       public $Label1 = null;
       public $JTRouteList = null;
       public $hiddenEmp = null;
       public $Image1 = null;
       public $JTSiteTheme1 = null;
       public $JTEmpList = null;
       function RouteLog2Create($sender, $params)
       {
       $emp = $_GET['emp'];
       $this->hiddenEmp->setValue($emp);

       $this->JTRouteList->setURL('route_list2.php?emp='.$this->hiddenEmp->getValue());

       $result_route = mysql_query("select * from vehicle_tbl where company_id='".$_SESSION['company_id']."'");
       $row_route = mysql_num_rows($result_route);

       if($row_route!=0)
       {
       if($emp==null || $emp=='')
        {
        $comp_id = $_SESSION['company_id'];
        $query_choose = "select * from vehicle_tbl where company_id='".$comp_id."' LIMIT 1";
        $result_choose = mysql_query($query_choose)or die(mysql_error());
        $row_choose = mysql_fetch_array($result_choose);
        $emp_id = $row_choose['vehicle_id'];
        //die($query1);
        if($emp_id!='' || $emp_id!=null)
        redirect('route_log_list2.php?emp='.$emp_id);
        }
       }

       }


       function JTEmpListShow($sender, $params)
       {
       $query1 = "select * from vehicle_tbl where company_id='".$_SESSION['company_id']."'";
       $result = mysql_query($query1)or die(mysql_error());

        $arr = array();
        while($row = mysql_fetch_array($result))
          {

            $emp = $row['vehicle_id'];

            if($this->hiddenEmp->getValue()==$emp)
            $radio = "<a href=route_log_list2.php?emp=".$emp."><img src='image/radio_select.png' border></a>";
            else
            $radio = "<a href=route_log_list2.php?emp=".$emp."><img src='image/radio.png' border></a>";

            /*$tools = "<a href=personnel_driving_list.php?emp=".$emp."><img src='image/emp_drivinghistory.png' title='driving history'></a>
            <a href=emp_license_create.php?emp=".$emp."><img src='image/emp_license.jpg' title='license'></a>
            <a href=emp_certification_list.php?emp=".$emp."><img src='image/emp_cert.jpg' title='certification'></a>";*/

            $photo = "<div align='center'><a href=personnel_edit.php?emp=".$emp."><img src='".$row['photo']."' height='50px' width='50px'></a></div>";

            $arr[] = array(
                        'Plate Number' => $radio.''.$row['veh_num'],
                        'Year' => $row['year'],
                        'Make' => $row['manufacturer_name'],
                        'Model' => $row['model_name']
                        );


          }

            $this->JTEmpList->setCellData($arr);


       }

}

global $application;

global $RouteLog2;

//Creates the form
$RouteLog2=new RouteLog2($application);

//Read from resource file
$RouteLog2->loadResource(__FILE__);

//Shows the form
$RouteLog2->show();

?>